#pragma once

#include <stdio.h>
#include <stdlib.h>
#include <time.h>

#define LOG(fmt, ...) do { \
	time_t timep; \
	time(&timep); \
	struct tm *p = gmtime(&timep); \
	printf("[%02d:%02d:%02d %s:%d]" fmt, p->tm_hour, p->tm_min, p->tm_sec, \
	__FILE__, __LINE__, ##__VA_ARGS__); \
	fflush(stdout); \
} while (0)

#define LOG_FATAL(fmt, ...) do { \
	LOG("[FATAL]" fmt, ##__VA_ARGS__); \
	exit(-1); \
} while (0)

#define LOG_WARN(fmt, ...) do { \
	LOG("[WARN]" fmt, ##__VA_ARGS__); \
	exit(-1); \
} while (0)
